<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %>
<%@include file="./../../../taglibs.jsp"%>
<html>
<head>
    <%@include file="./../../../header.jsp"%>
</head>
	<body class="body">
		<div class="section">
			<div class="wrapper-md">
	       		<h1 class="fl" id="title">工作轨迹</h1>
	        </div>
			<div class="section-content">
				<div class="layui-form filterDiv">
					<div class="layui-inline">
						<label for="">选择社区：</label>
						<div class="layui-input-inline">
						    <select>
						        <option value="0">全部</option>
						        <option value="1">交通运输部</option>
						        <option value="2">厅机关</option>
						        <option value="3">厅直单位</option>
						        <option value="4">地市交通局</option>
					      	</select>
				      	</div>
					</div>
					<button class="def-btn def-btn-normal ml20"><i class="gopng gopng_search"></i> 查询</button>
				</div>
				<div class="layui-form">
					<div id="map_container" tabindex="0">

					</div>
				</div>
			</div>
		</div>
		
		
		
		
		
		
		
		<script src="http://webapi.amap.com/maps?v=1.4.0"></script>
		<script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
		<script src="http://cache.amap.com/lbs/static/addToolbar.js"></script>

		
		<script type="text/javascript">
			var form = layui.form,
				layer = layui.layer,
				layedit = layui.layedit,
				laydate = layui.laydate
	
				form.render()
			
			
			//获取工作轨迹用户
			
			var map = new AMap.Map('map_container',{resizeEnable: true,zoom:10});
			
			function gettrajectory(communityId,suc){
				if(communityId&&typeof communityId == 'function'){
					suc = communityId;
					communityId='';
				}
				$.ajax({
					type:"post",
					url:"/app/trajectory/show_point",
					data:{
						communityId:communityId
					},
					async:true,
					success:function(res){
						if(res.code=='C10000'){
							if(suc&&typeof suc == 'function'){
								suc(res.data)
							}
						}else{
							layer.msg('数据获取失败', {icon: 5});
						}
					},
					error:function(err){
						layer.msg('数据获取失败', {icon: 5});
					}
				});
				
			}
			
			function renderMap(mapData){
				for(var i = 0; i < mapData.length; i += 1){
				    marker = new AMap.Marker({
						clickable:true,
						content: '<div class="marker-route ">'+
							'<div class="marker-marker-icon"></div>'+
							'<div class="marker-marker-uname">'+mapData[i].realName+'</div>'+
						'</div>',   //自定义点标记覆盖物内容
						position: [mapData[i].coordinatex,mapData[i].coordinatey],
						title: mapData[i].realName,
						userId:mapData[i].userId
					});
					AMap.event.addListener(marker, 'click', function(e){
						var userId =  e.target.F.userId;
						markClick(userId)
					});
					marker.setMap(map);
				}
			}
			
			
			
			function markClick(userId){
				location.href="detail.html"
			}
			
			

			//初始化
			gettrajectory(function(data){
				renderMap(data)
			})
			


		</script>
	</body>
</html>